<template>
	<view @click="navigate('/page_pack/food/detail?id='+info.id)" class="food-item" :style="style">
		<image :src="info.coverImage" mode="aspectFill" class="food-cover"></image>
		<view class="food-info">
			<view class="title">{{info.title}}</view>
			<view class="description">{{info.account||''}}</view>
			<view class="address">
				<view class="iconfont icon-dingxiang"></view>
				<view class="text">{{info.address}}</view>
				<view class="distance">{{info.distance}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		name:'FoodItem',
		computed:{
			style(){
				return this.background=='rgba(0,0,0,0)'?'border-bottom:1px solid #e7e7e7;margin:0rpx;background:'+this.background:'background:'+this.background;
			}
		},
		props:{
			background:{
				type:String,
				default:'rgba(0,0,0,0)'
			},
			info:{
				type:Object,
				default:()=>{
					return{
						coverImage:'',
						title:'',
						address:'',
						distance:'未知',
					}
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.food-item{
		width: 100%;
		height:220rpx;
		border-radius: 8px;
		background: #fff;
		display: flex;
		align-items: center;
		padding:30rpx;
		margin-bottom: 20rpx;
		.food-cover{
			width: 160rpx;
			height: 160rpx;
			border-radius: 8px;
			margin-right: 20rpx;
		}
		.food-info{
			width: calc(100% - 180rpx);
			height: 100%;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			.title{
				width: 100%;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
				font-size: 34rpx;
				font-weight: bold;
			}
			.description{
				width: 100%;
				font-size: 28rpx;
				color: #999;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
			}
			.address{
				width: 100%;
				display: flex;
				align-items: center;
				>view{
					color: #767676;
				}
				.iconfont{
					width: 36rpx;
				}
				.text{
					width: calc(100% - 170rpx);
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
				}
				.distance{
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
					width: 120rpx;
					text-align: right;
				}
			}
		}
	}
</style>